const letterMap = {
    '2': ['a', 'b', 'c'],
    '3': ['d', 'e', 'f'],
    '4': ['g', 'h', 'i'],
    '5': ['j', 'k', 'l'],
    '6': ['m', 'n', 'o'],
    '7': ['p', 'q', 'r', 's'],
    '8': ['t', 'u', 'v'],
    '9': ['w', 'x', 'y', 'z']
};

function backtrack(current, index){
    if(index == digits.length){
        result.push(current.join(''))
        return
    }
    let digit = digits[index];
    let letters = letterMap[digit]
    for(let i = 0; i < letters.length; i++){
        current.push(letters[i])
        backtrack(current, index + 1)
        current.pop()
    }

}

let digits = '23'
let result = []

backtrack([], 0)

console.log(result)